package cn.edu.lzu.dao;

import cn.edu.lzu.entity.RadiologyExamineItem;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @PackageName: cn.edu.lzu.dao
 * @InterfaceName: RadiologyExamineItemMapper
 * @Description: TODO
 * @Author: 张琦[QQ:3098086691]
 * @Date: 2020/3/23 21:04
 * @Version: 1.0
 */
@Mapper
public interface RadiologyExamineItemMapper {
    @Select("select * from radiology_examine_item where is_deleted=0 and unit_id=#{unitId} limit #{startIndex}, #{pageSize}")
    List<RadiologyExamineItem> selRadItemsByUnitId(long unitId, int startIndex, int pageSize);

    @Select("select count(*) from radiology_examine_item where is_deleted=0 and unit_id=#{unitId}")
    int selTotalCountRadItemsByUnitId(long unitId);

    @Insert("insert into radiology_examine_item (examine_item_id, examine_name, examine_area, examine_method, apply_range, apply_sex, price, is_deleted, unit_id) values(default, #{examineName}, #{examineArea}, #{examineMethod}, #{applyRange}, #{applySex}, #{price}, 0, #{unitId})")
    int insRadItem(RadiologyExamineItem radiologyExamineItem);

    @Update("update radiology_examine_item set is_deleted=1 where examine_item_id=#{examineItemId}")
    int updDeleteRadItemById(int examineItemId);

    @Select("select * from radiology_examine_item where is_deleted=0 and unit_id=#{unitId} and examine_name like concat('%', #{examineName}, '%')")
    List<RadiologyExamineItem> selFuzzyRadItemByName(long unitId, String examineName);

    @Select("select * from radiology_examine_item where is_deleted=0 and unit_id=#{unitId} and examine_area like concat('%', #{examineArea}, '%')")
    List<RadiologyExamineItem> selFuzzyRadItemByArea(long unitId, String examineArea);

    @Select("select * from radiology_examine_item where is_deleted=0 and unit_id=#{unitId} and examine_method like concat('%', #{examineMethod}, '%')")
    List<RadiologyExamineItem> selFuzzyRadItemByMethod(long unitId, String examineMethod);

    @Select("select * from radiology_examine_item where is_deleted=0 and unit_id=#{unitId}")
    List<RadiologyExamineItem> selAllRadItems(long unitId);

    @Select("select * from radiology_examine_item where is_deleted=0 and examine_item_id=#{examineItemId}")
    RadiologyExamineItem selByExamineItemId(int examineItemId);

}
